//
//  UIButton+Extensions.swift
//  status
//
//  Created by 彳亍 on 2017/3/22.
//  Copyright © 2017年 彳亍. All rights reserved.
//

import UIKit

extension UIButton {
    
    /// 便利构造器
    ///
    /// - Parameters:
    ///   - title: 标题
    ///   - titleColor: 标题颜色
    ///   - fontSize: 标题字体
    ///   - backgroundImage: 背景图片
    ///   - image: 配图
    ///   - target: 监听者
    ///   - action: 监听方法
    convenience init(title:String,titleColor:UIColor,fontSize:CGFloat = 14,backgroundImage:UIImage?,image:UIImage? = nil,target:Any?,action:Selector) {
        self.init(type:UIButtonType.custom)
        setTitle(title, for: UIControlState.normal)
        setTitleColor(titleColor, for: UIControlState.normal)
        titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
        setImage(image, for: UIControlState.normal)
        setBackgroundImage(backgroundImage, for: UIControlState.normal)
        sizeToFit()
        addTarget(target, action: action, for: UIControlEvents.touchUpInside)
    }


}
